package org.wu.framework.authorization.platform.infrastructure.persistence;

import org.wu.framework.authorization.platform.infrastructure.entity.LazyZoneApplicationVersionDO;
import org.wu.framework.authorization.platform.infrastructure.converter.LazyZoneApplicationVersionConverter;
import org.wu.framework.authorization.platform.infrastructure.mapper.LazyZoneApplicationVersionMapper;
import org.wu.framework.authorization.platform.domain.model.lazy.zone.application.version.LazyZoneApplicationVersionRepository;
import org.springframework.stereotype.Repository;
import java.util.stream.Collectors;
import org.wu.framework.lazy.orm.database.lambda.stream.wrapper.LazyWrappers;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.response.ResultFactory;
import jakarta.annotation.Resource;
import org.wu.framework.authorization.platform.domain.model.lazy.zone.application.version.LazyZoneApplicationVersion;
import org.wu.framework.lazy.orm.database.lambda.stream.lambda.LazyLambdaStream;
import java.util.List;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
/**
 * describe 应用版本 
 *
 * @author Jia wei Wu
 * @date 2024/04/02 06:21 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyInfrastructurePersistence 
 **/
@Repository
public class LazyZoneApplicationVersionRepositoryImpl  implements  LazyZoneApplicationVersionRepository {

    @Resource
    LazyLambdaStream lazyLambdaStream;

    /**
     * describe 新增应用版本
     *
     * @param lazyZoneApplicationVersion 新增应用版本     
     * @return {@link Result<LazyZoneApplicationVersion>} 应用版本新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyZoneApplicationVersion> story(LazyZoneApplicationVersion lazyZoneApplicationVersion) {
        LazyZoneApplicationVersionDO lazyZoneApplicationVersionDO = LazyZoneApplicationVersionConverter.INSTANCE.fromLazyZoneApplicationVersion(lazyZoneApplicationVersion);
        lazyLambdaStream.upsert(lazyZoneApplicationVersionDO);
        return ResultFactory.successOf();
    }

    /**
     * describe 批量新增应用版本
     *
     * @param lazyZoneApplicationVersionList 批量新增应用版本     
     * @return {@link Result<List<LazyZoneApplicationVersion>>} 应用版本新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<List<LazyZoneApplicationVersion>> batchStory(List<LazyZoneApplicationVersion> lazyZoneApplicationVersionList) {
        List<LazyZoneApplicationVersionDO> lazyZoneApplicationVersionDOList = lazyZoneApplicationVersionList.stream().map(LazyZoneApplicationVersionConverter.INSTANCE::fromLazyZoneApplicationVersion).collect(Collectors.toList());
        lazyLambdaStream.upsert(lazyZoneApplicationVersionDOList);
        return ResultFactory.successOf();
    }

    /**
     * describe 查询单个应用版本
     *
     * @param lazyZoneApplicationVersion 查询单个应用版本     
     * @return {@link Result<LazyZoneApplicationVersion>} 应用版本领域对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyZoneApplicationVersion> findOne(LazyZoneApplicationVersion lazyZoneApplicationVersion) {
        LazyZoneApplicationVersionDO lazyZoneApplicationVersionDO = LazyZoneApplicationVersionConverter.INSTANCE.fromLazyZoneApplicationVersion(lazyZoneApplicationVersion);
        LazyZoneApplicationVersion lazyZoneApplicationVersionOne = lazyLambdaStream.selectOne(LazyWrappers.lambdaWrapperBean(lazyZoneApplicationVersionDO), LazyZoneApplicationVersion.class);
        return ResultFactory.successOf(lazyZoneApplicationVersionOne);
    }

    /**
     * describe 查询多个应用版本
     *
     * @param lazyZoneApplicationVersion 查询多个应用版本     
     * @return {@link Result<List<LazyZoneApplicationVersion>>} 应用版本领域对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<List<LazyZoneApplicationVersion>> findList(LazyZoneApplicationVersion lazyZoneApplicationVersion) {
        LazyZoneApplicationVersionDO lazyZoneApplicationVersionDO = LazyZoneApplicationVersionConverter.INSTANCE.fromLazyZoneApplicationVersion(lazyZoneApplicationVersion);
        List<LazyZoneApplicationVersion> lazyZoneApplicationVersionList = lazyLambdaStream.selectList(LazyWrappers.lambdaWrapperBean(lazyZoneApplicationVersionDO), LazyZoneApplicationVersion.class);
        return ResultFactory.successOf(lazyZoneApplicationVersionList);
    }

    /**
     * describe 分页查询多个应用版本
     *
     * @param size 当前页数
     * @param current 当前页
     * @param lazyZoneApplicationVersion 分页查询多个应用版本     
     * @return {@link Result<LazyPage<LazyZoneApplicationVersion>>} 分页应用版本领域对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyPage<LazyZoneApplicationVersion>> findPage(int size,int current,LazyZoneApplicationVersion lazyZoneApplicationVersion) {
        LazyZoneApplicationVersionDO lazyZoneApplicationVersionDO = LazyZoneApplicationVersionConverter.INSTANCE.fromLazyZoneApplicationVersion(lazyZoneApplicationVersion);
        LazyPage<LazyZoneApplicationVersion> lazyPage = new LazyPage<>(current,size);
        LazyPage<LazyZoneApplicationVersion> lazyZoneApplicationVersionLazyPage = lazyLambdaStream.selectPage(LazyWrappers.lambdaWrapperBean(lazyZoneApplicationVersionDO),lazyPage, LazyZoneApplicationVersion.class);
        return ResultFactory.successOf(lazyZoneApplicationVersionLazyPage);
    }

    /**
     * describe 删除应用版本
     *
     * @param lazyZoneApplicationVersion 删除应用版本     
     * @return {@link Result<LazyZoneApplicationVersion>} 应用版本     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyZoneApplicationVersion> remove(LazyZoneApplicationVersion lazyZoneApplicationVersion) {
        LazyZoneApplicationVersionDO lazyZoneApplicationVersionDO = LazyZoneApplicationVersionConverter.INSTANCE.fromLazyZoneApplicationVersion(lazyZoneApplicationVersion);
        //  lazyLambdaStream.delete(LazyWrappers.lambdaWrapperBean(lazyZoneApplicationVersionDO));
        return ResultFactory.successOf();
    }

    /**
     * describe 是否存在应用版本
     *
     * @param lazyZoneApplicationVersion 应用版本领域对象     
     * @return {@link Result<Boolean>} 是否存在 true 存在，false 不存在     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<Boolean> exists(LazyZoneApplicationVersion lazyZoneApplicationVersion) {
        LazyZoneApplicationVersionDO lazyZoneApplicationVersionDO = LazyZoneApplicationVersionConverter.INSTANCE.fromLazyZoneApplicationVersion(lazyZoneApplicationVersion);
        Boolean exists=lazyLambdaStream.exists(LazyWrappers.lambdaWrapperBean(lazyZoneApplicationVersionDO));
        return ResultFactory.successOf(exists);
    }

}